//
//  LBIMUserInfoDataSource.m
//  app
//
//  Created by 刘文扬 on 16/8/19.
//  Copyright © 2016年 广东联结电子商务有限公司. All rights reserved.
//

#import "LBIMUserInfoDataSource.h"
#import "LBIMManager.h"
#import "LBRongYunKitHead.h"
@implementation LBIMUserInfoDataSource

+(instancetype)shareInstance
{
    static __kindof LBIMUserInfoDataSource *sharedInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedInstance=[[[self class] alloc] init];
        
    });
    
    return sharedInstance;
}

-(void)getUserInfoWithUserId:(NSString *)userId completion:(void (^)(RCUserInfo *))completion
{
//    RCUserInfo *defaultUserInfo = [[RCUserInfo alloc] initWithUserId:userId name:@" " portrait:nil];
//    completion(defaultUserInfo);
    [LBIMManager  getUserInfoWithIMUserId:userId success:^(LBIMUserInfo *userInfo) {
        
        RCUserInfo *imUserInfo = nil;
        if (userInfo.userId < 0.0) {
            imUserInfo = [[RCUserInfo alloc] initWithUserId:userId name:@"客服小蜜" portrait:userInfo.userPic];
            completion(imUserInfo);
        }else{
            if (IsStrEmpty(userInfo.userNickName)) {
                completion(nil);
            }else{
                imUserInfo = [[RCUserInfo alloc] initWithUserId:userId name:userInfo.userNickName portrait:userInfo.userPic];
                completion(imUserInfo);
            }
        }
//
//        return;
        
    } fail:^(NSString *message) {
        completion(nil);

    }];
}

//-(void)getAllMembersOfGroup:(NSString *)groupId result:(void (^)(NSArray<NSString *> *))resultBlock
//{
//    [LBJobManager getImIdsWithGroupId:groupId success:^(NSDictionary *data) {
//
//        NSArray *imids = [NSString mj_objectArrayWithKeyValuesArray:data];
//        resultBlock(imids);
//
//
//    } fail:^(NSString *message) {
//        [LBLoadingView dismiss];
//        [LBAlert say:message];
//    }];
//}



@end
